package calao.client.ui;

import calao.client.i18n.Text;
import calao.client.ui.SpacerPanel;
import calao.client.Desktop;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;

abstract public class ConfirmBox extends DialogBox 
{

	final Text text = Desktop.getDesktop().text;

	HTML message = new HTML();
	
	public ConfirmBox()
	{
		SpacerPanel panel = new SpacerPanel(SpacerPanel.VERTICAL);
		SpacerPanel buttons = new SpacerPanel(SpacerPanel.HORIZONTAL);
		Button cancel = new Button(text.cancel());
		cancel.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				hide();
			}
		});
		Button ok = new Button(text.ok());
		ok.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				confirm();
				hide();
			}
		});
		buttons.add(cancel);
		buttons.add(ok);
		panel.add(message);
		panel.add(buttons);
		panel.setWidth("400px");	
		setWidget(panel);
	}
	
	abstract public void confirm();
	
	public void setMessage(String text)
	{
		message.setText(text);		
	}
		
}
